Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
@types/proj4
Advanced tools
Package description
@types/proj4 provides TypeScript type definitions for the proj4 library, which is used for cartographic projections and coordinate transformations.
Coordinate Transformation
This feature allows you to transform coordinates from one projection system to another. In this example, coordinates in EPSG:4326 (WGS 84) are transformed to EPSG:3857 (Web Mercator).
const proj4 = require('proj4');
const firstProjection = 'EPSG:4326';
const secondProjection = 'EPSG:3857';
const coordinates = [2.2945, 48.8584];
const transformedCoordinates = proj4(firstProjection, secondProjection, coordinates);
console.log(transformedCoordinates);
Defining Custom Projections
This feature allows you to define custom projections. In this example, a custom UTM projection is defined and then used to transform coordinates to EPSG:4326.
const proj4 = require('proj4');
const customProjection = '+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs';
proj4.defs('EPSG:32633', customProjection);
const coordinates = [500000, 4649776.22482];
const transformedCoordinates = proj4('EPSG:32633', 'EPSG:4326', coordinates);
console.log(transformedCoordinates);
Batch Transformations
This feature allows you to perform batch transformations on an array of coordinates. In this example, an array of coordinates in EPSG:4326 is transformed to EPSG:3857.
const proj4 = require('proj4');
const firstProjection = 'EPSG:4326';
const secondProjection = 'EPSG:3857';
const coordinatesArray = [[2.2945, 48.8584], [13.4050, 52.5200]];
const transformedCoordinatesArray = coordinatesArray.map(coords => proj4(firstProjection, secondProjection, coords));
console.log(transformedCoordinatesArray);
The proj4 package is the core library for performing cartographic projections and coordinate transformations. It provides the same functionalities as @types/proj4 but without TypeScript type definitions.
The geodesy package provides tools for geodetic calculations, including coordinate transformations, distance calculations, and more. It offers a broader range of geodetic functionalities compared to @types/proj4.
The terraformer package is a library for converting geographic data between different formats and performing spatial operations. While it includes coordinate transformation capabilities, it also offers additional functionalities like spatial indexing and GeoJSON support.
Readme
npm install --save @types/proj4
This package contains type definitions for proj4 (https://github.com/proj4js/proj4js).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/proj4.
These definitions were written by Denis Carriere, and BendingBender.
FAQs
TypeScript definitions for proj4
The npm package @types/proj4 receives a total of 56,506 weekly downloads. As such, @types/proj4 popularity was classified as popular.
We found that @types/proj4 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.